<template>
  <div>
    <div class="cashPop" ref="cashPopHf">
    <div class="cashPop-main">
      <div class="cashPop_close">
        佣金提现
        <i @click="closeCashPop"></i>
      </div>
    </div>
    <div class="cashCard">
      <div class="cashCard-main">
        <div class="card-wrap-title">银行卡号</div>
        <div class="card-wrap-num">{{cashPopData.adapay_card_no}}</div>
      </div>
    </div>
    <div class="cashPop-main">
      <div class="balance_inputinfo">
        <div class="money_number">
          <h3>提现金额</h3>
          <p>
            <b>{{mSymbol.name}}</b>
            <input type="text"
              placeholder="请输入提现金额"
              v-model="money" />
          </p>
          <div>
            <span>温馨提示</span>
            <p class="Tips"
               style="line-height: 20px;font-size: 13px;color: #999;font-weight: normal;border:0;">{{cashPopData.draw_alert}}</p>
          </div>
        </div>
      </div>
      <div class="balance_inputinfo" v-if="cashPopData.is_open_adapay_remark">
        <div class="money_number">
          <h3>提现信息</h3>
          <p>
            <textarea :placeholder="cashPopData.adapay_placeholder" v-model="remark"></textarea>
          </p>
        </div>
      </div>

      <div class="count_node clearfix">
        <div>
          <span
                @click="clickTxBtn()"
                class="count-btn count-ico"
                :key="'wfx'">确认提现</span>
        </div>
      </div>
    </div>
  </div>
  </div>
</template>
<script>
import { doTX } from '@/api/user/fxs/fxsApi'
import { mapGetters } from 'vuex'
import { doSupplierWithdraw } from '@/api/user/gys/gysApi'

export default {
  props: {
    cashPopData: {
      type: Object,
      default: {
        adapay_card_no: '',
        remark: ''
      }
    },
    cashPop: {
      type: Object,
      default: {
        code: ''
      }
    },
    supplierWithdraw: {
      type: [Number, String],
      default: 0
    }
  },
  data() {
    return {
      money: ''
    }
  },
  computed: {
    // 获取自定义符号
    ...mapGetters(['mSymbol'])
  },
  methods: {
    closeCashPop() {
      this.$emit('closePop')
    },
    clickTxBtn() {
      if (Number(this.money) == 0 || Number(this.money) == '') {
        this.$Error('请填写正确的提示金额')
      } else if (Number(this.money) > Number(this.cashPopData.user_account)) {
        this.$Error(`提现金额不能大于佣金金额(${this.cashPopData.user_account}元)`)
      } else if (this.cashPopData.step != 2) {
        this.$Error('账户未开户，请先开户')
        this.$emit('adapayStep', this.cashPopData)
      } else {
        if (this.supplierWithdraw) {
          doSupplierWithdraw({
            type: 8,
            money: this.money,
            code: this.cashPop.code
          }).then(res => {
            this.$loadingWrap.close()
            if (res.status == 1) {
              this.$Error(res.data.msg || res.msg)
              setTimeout(() => {
                window.location.reload()
              }, 1000)
            } else {
              this.$Error(res.msg.msg || res.msg)
            }
          })
        } else {
          doTX({
            type: 8,
            money: this.money,
            code: this.cashPop.code,
            adapay_withdraw_remark: this.remark
          }).then(res => {
            this.$loadingWrap.close()
            if (res.status == 1) {
              this.$Error(res.data.msg)
              setTimeout(() => {
                window.location.reload()
              }, 1000)
            } else {
              this.$Error(res.msg.msg || res.msg)
            }
          })
        }
      }
    }
  }
}
</script>

<style lang="scss">
@import "src/styles/variables.scss";
.cashPop {
  position: relative;
  height: 100%;
  overflow:auto;
  background-color: #f5f5f5;
  .cashPop_close {
    position: relative;
    font-weight: bold;
    font-size: 28px;
    color: #333;
    height: 92px;
    text-align: center;
    padding: 30px;
    background-color: #fff;
    i{
      position: absolute;
      right: 30px;
      top: 50%;
      display: inline-block;
      width: 28px;
      height: 28px;
      background: url("https://img.wifenxiao.com/h5-wfx/images/user/icon_del.png") center
        no-repeat;
      background-size: 100% 100%;
      transform: translateY(-50%);
    }
  }
  .cashCard {
    border-radius: 10px;
    margin: 20px 0;
    background:#fff url('https://img.wifenxiao.com/h5-wfx/images/user/balanceBg.png') center no-repeat;
    background-size: 100% 100%;
    position: relative;
    &-main{
      padding: 50px 50px;
      color: #333;
      .card-wrap-title {
        font-size: 28px;
      }
      .card-wrap-num{
        font-size: 34px;
        margin-top: 30px;
        margin-bottom: 50px;
      }
    }
  }

  &-main {
    background-color: #f5f5f5;

    .balance_inputinfo {
      background-color: #fff;
      padding: 0;
      margin: 20px;
      border: 0;
      padding-left: 30px;
      margin: 20px;
      border-radius:20px;
      font-size: 28px;
      h3 {
        font-size: 28px;
        line-height: 90px;
        font-weight: normal;
      }
      .money_number {
        padding-bottom: 4px;

        p {
          font-size: 40px;
          line-height: 56px;
          padding-bottom: 30px;
          padding-right: 30px;
          border-bottom: 2px solid #eee;
          b{
            font-weight:bold;
          }
          input {
            border: none;
            outline: none;
          }
          textarea {
            font-size: 28px;
            width: 100%
          }
        }
        .phone-code {
          margin-top: 30px;
          height: 90px;
          &-input {
            width: 50%;
            float: left;
          }
          &-get {
            color: $light-blue;
            float: right;
            outline: none;
            border: none;
            background: none;
          }
        }
        span {
          line-height: 92px;
          font-size: 26px;
          color: #999;
        }
        .Tips {
          line-height: 40px;
          font-size: 26px;
          color: #999;
          font-weight: normal;
          border: 0;
          margin-top: -10px;
        }
      }
    }
    .count_node {
      padding: 0 30px;
      margin-top: 30px;
      span {
        display: block;
        width: auto;
        height: 80px;
        line-height: 80px;
        text-align: center;
        color: #fff;
        border-radius: 80px;
        margin: 0px auto;
        margin: 20px 0;
        font-size: 28px;
        background: linear-gradient(
          -90deg,
          rgba(233, 1, 4, 1),
          rgba(254, 27, 73, 1)
        );
      }
    }
  }
}
</style>
